home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / mail-tools / thor / scripts / ambbs.ncomm.script next >
Text File  |  1996-02-26  |  29KB  |  1,295 lines

  1. ; $VER: AMBBS.NComm.script 4.2 (4.10.95)
  2. ; ABBS/MBBS NComm Script for THOR
  3. ; By Eivind Nordseth, Ultima Thule Software
  4.  
  5.     REQUEST OFF
  6.  
  7.     set $dox = ""
  8.     set $oldconf = ""
  9.     set $gethold = "FALSE"
  10.     set $fixtimeout = ""
  11.     set $dtmpfile = ""
  12.     set $readmode = ""
  13.     set $private = ""
  14.     set $userinfo = "FALSE"
  15.     set $repfile = ""
  16.     set $qwkcommand = "Q QWK"
  17.     set $qwkcfg = "FALSE"
  18.     set $qwkerr = "TRUE"
  19.     set $rengrab = ""
  20.     set $doctrlx = "FALSE"
  21.     set $done = "FALSE"
  22.     set $notify = ""
  23.     set $packageOK = "FALSE"
  24.     set $gotprivfiles = "FALSE"
  25.     set $newfilesdate = ""
  26.  
  27.     when "EMSI_REQ" gosub AFrontDetect
  28.     cli $THORPath"bin/ScriptServ \""$BBSName"\" WRITECFG EV 0 EV 1 EV 2 EV 3 EV 4 EV 5 EV 6 EV 7 EV 8 EV 10 EV 11 EV 12 EV 13 EV 14"
  29.  
  30.     if exists "t:privupl"$BBSName then cli "delete >nil: \"t:privupl"$BBSName"\""
  31.     if exists "t:filenote"$BBSName then cli "delete >nil: \"t:filenote"$BBSName"\""
  32.     if exists "t:NoLogOut" then cli "delete >nil: t:NoLogOut"
  33.     if exists "t:DoLogOut" then cli "delete >nil: t:DoLogOut"
  34.  
  35.     varfile "t:"$BBSName".CONFIG"
  36.  
  37.     readvar $CfgVer
  38.     readvar $BBSID
  39.     readvar $BBSType
  40.     readvar $Path
  41.     readvar $PostConf
  42.     readvar $UpLoadDir
  43.     readvar $UserName
  44.     readvar $UserStreet
  45.     readvar $UserAddress
  46.     readvar $UserCountry
  47.     readvar $UserPhone
  48.     readvar $NewFiles
  49.     readvar $AutoPDnl
  50.     readvar $AutoLogoff
  51.     readvar $UseColors
  52.     readvar $AnsiMenues
  53.     readvar $Bulletins
  54.     readvar $ReplyPacket
  55.     varfile close
  56.  
  57.     if !$CfgVer == "4" then message "Incompatible version of ScriptServ"
  58.     if !$CfgVer == "4" then goto AllDone
  59.  
  60.     if $ReplyPacket == "" then set $ReplyPacket = $BBSID".REP"
  61.  
  62.     cli "delete >nil: \"t:"$BBSName".CONFIG\""
  63.  
  64.     set $LogFile = $Path"ScriptMsg.txt"
  65.  
  66.     when "\r\nNO CARRIER\r\n" goto AllDone
  67.     send "^K\n\n"
  68.  
  69.     autoxfer off ; Turn off G&R commands
  70.     autoup off   ; Turn off Zmodem autoupload
  71.     autodown on  ; Turn on Zmodem autodownload
  72.  
  73.     if $BBSType == "MBBS"     then menuselect TRANSLATE 1 8 ; Use IBN character set
  74.     if $BBSType == "MBBS"     then set $charset = "IBN"     ; Use IBN character set
  75.     if $BBSType == "ABBS"     then menuselect TRANSLATE 1 0 ; Use ISO character set
  76.     if $BBSType == "ABBS"     then set $charset = "ISO"     ; Use ISO character set
  77.     if $BBSType == "MBBS_QWK" then menuselect TRANSLATE 1 8 ; Use IBN character set
  78.     if $BBSType == "MBBS_QWK" then set $charset = "IBN"     ; Use IBN character set
  79.     if $BBSType == "ABBS_QWK" then menuselect TRANSLATE 1 0 ; Use ISO character set
  80.     if $BBSType == "ABBS_QWK" then set $charset = "ISO"     ; Use IBN character set
  81.  
  82.     converse "FIRST name" $UserName" Q\n"
  83.  
  84.     if $BBSType == "ABBS_QWK" then menuselect TRANSLATE 1 8 ; Use IBN character set
  85.     if $BBSType == "ABBS_QWK" then set $charset = "IBN"     ; Use IBN character set
  86.  
  87.     converse "will echo):" "\p\n"
  88.  
  89.     dwhen "EMSI_REQ"
  90.  
  91.     capture "t:privupl"$BBSName
  92.  
  93.     when "--more--" send "C"
  94.     when "coming online" gosub SysOp
  95.     when "The following" set $gotprivfiles = "TRUE"
  96.  
  97.     if $BBSType == "MBBS"     then set $docmd = "CHAT N U L 0 MF 50 S IBN\n"
  98.     if $BBSType == "ABBS"     then set $docmd = "CHAT N U L 0 MF 50 S ISO\n"
  99.     if $BBSType == "MBBS_QWK" then set $docmd = "CHAT N U L 0 MF 50 S IBN\n"
  100.     if $BBSType == "ABBS_QWK" then set $docmd = "CHAT N U L 0 MF 50 S IBN\n"
  101.     gosub DoCommand
  102.  
  103. ;***************** Event loop
  104.     
  105.     wait "Command"
  106.     set $doctrlx = "TRUE"
  107.  
  108.     dwhen "The following"
  109.     capture off
  110.  
  111.     if !exists "t:"$BBSName".EVENTS" then goto afterEvents
  112.     varfile "t:"$BBSName".EVENTS"
  113.  
  114. eventLoop:
  115.     set $done = "FALSE"
  116.  
  117.     readvar $eventnr
  118.     readvar $event
  119.  
  120.     if $eventnr == "EOF" then goto evLoopEnd
  121.     if $event   == "EOF" then goto evLoopEnd
  122.  
  123.     if $event == "0"  then gosub EnterMsg
  124.     if $event == "1"  then gosub ReplyMsg
  125.     if $event == "2"  then gosub JoinConf
  126.     if $event == "3"  then gosub ResignConf
  127.     if $event == "4"  then gosub DownloadFile
  128.     if $event == "5"  then gosub UploadFile
  129.     if $event == "6"  then gosub GetConfList
  130.     if $event == "7"  then gosub ConfigureBBS
  131.     if $event == "8"  then gosub SendUserInfo
  132.     if $event == "10" then gosub GetNewFiles
  133.     if $event == "11" then gosub CommandEvent
  134.     if $event == "12" then gosub AutoLogOff
  135.     if $event == "13" then gosub RetractMsg
  136.     if $event == "14" then gosub RetractFile
  137.  
  138.     if $event == "7769"  then set $done = "TRUE"
  139.  
  140.     if  $done == "TRUE" then cli "run >nil: "$THORPath"bin/ScriptServ \""$BBSName"\" DONE "$eventnr
  141.     if !$done == "TRUE" then cli "run >nil: "$THORPath"bin/ScriptServ \""$BBSName"\" ERROR "$eventnr
  142.  
  143.     goto eventLoop    
  144.  
  145. evLoopEnd:
  146.     varfile close
  147.  
  148.     cli "delete >nil: \"t:"$BBSName".EVENTS\""
  149.  
  150. afterEvents:
  151.  
  152. ;***************** Grab messages
  153.  
  154.     set $rengrab = "y"
  155.  
  156.     if $BBSType == "ABBS_QWK" then goto HandleABBSQWK
  157.  
  158.     if $BBSType == "ABBS"     then set $docmd = "U GF MBBS\n"
  159.     if $BBSType == "ABBS"     then gosub DoCommand
  160.  
  161.     set $packageOK = "TRUE"
  162.  
  163.     set $docmd = "R DUMP ALL\n"
  164.     gosub DoCommand
  165.  
  166.     when "<0>" goto grabd
  167.  
  168.     converse "Command" "SE Z\n"
  169.  
  170. grabd:
  171.     dlwhen
  172.     goto AfterGrabing
  173.  
  174.  
  175. ;***************** Do ABBS_QWK packet handling
  176. HandleABBSQWK:
  177.     set $docmd = "U GF QWK\n"
  178.     gosub DoCommand
  179.  
  180.     if !exists $UpLoadDir$ReplyPacket then goto NoABBSRepFile
  181.     
  182.     set $docmd = "Q MU\n"
  183.     gosub DoCommand
  184.  
  185.     when "parsed successfully" set $qwkerr = "FALSE"
  186.  
  187.     wait "B01"
  188.     upload $UpLoadDir$ReplyPacket,Z
  189.     gosub NoTimeout
  190.  
  191.     capture $Path"QWKMsg.txt"
  192.  
  193.     wait "Main Command"
  194.  
  195.     capture off
  196.     dlwhen
  197.     gosub SetUpTimeout
  198.  
  199.     if $qwkerr == "TRUE" then goto ABBSRepFileFail
  200.  
  201.     set $packageOK = "TRUE"
  202.  
  203.     cli "delete >nil: "$UpLoadDir$ReplyPacket
  204.     cli "delete >nil: "$Path"QWKMsg.txt"
  205.     set $doctrlx = "TRUE"
  206.     goto NoABBSRepFile
  207.  
  208. ABBSRepFileFail:
  209.     set $appendsource = $Path"QWKMsg.txt"
  210.     set $appenddest = $LogFile
  211.     gosub AppendFile
  212.     set $doctrlx = "TRUE"
  213.  
  214. NoABBSRepFile:
  215.     set $docmd = "R DUMP ALL\n"
  216.     gosub DoCommand
  217.     gosub NoTimeout
  218.  
  219.     when "<0>" goto grabQwkDone
  220.  
  221.     converse "Command" "SE Z\n"
  222.  
  223. grabQwkDone:
  224.     dlwhen
  225.     goto AfterGrabing
  226.  
  227. ;***************** Package Done
  228. AfterGrabing:
  229.     set $doctrlx = "TRUE"
  230.     wait "Command"
  231.  
  232.     if $packageOK == "TRUE" then cli "run >nil: "$THORPath"bin/ScriptServ \""$BBSName"\" PACKAGEDONE"
  233.     set $rengrab = "y"
  234.  
  235. ;***************** Capture Newfiles.txt
  236.  
  237.     if !$NewFiles == "y" then goto AfterNewFiles
  238.  
  239.     set $docmd = ""
  240.     gosub DoCommand
  241.  
  242.     when "Detailed list (Enter=N):" send "n\n"
  243.  
  244.     cli "Delete >nil: "$Path"Newfiles.txt"
  245.     capture $Path"Newfiles.txt"
  246.  
  247.     if $newfilesdate == "" then set $newfilesdate = ";"
  248.     send "F N "$newfilesdate" ;\n"
  249.     gosub NoTimeout
  250.  
  251.     when "Read Command" goto NewFilesDone
  252.     wait "File Command"
  253.  
  254. NewFilesDone:
  255.     dwhen "Read Command"
  256.     dwhen "Detailed list (Enter=N):"
  257.     capture off
  258.     set $doctrlx = "TRUE"
  259.  
  260. AfterNewFiles:
  261. ;***************** Auto dnload private files
  262.  
  263.     if !$AutoPDnl == "y" then goto NoPrivUpl
  264.     if !$gotprivfiles == "TRUE" then goto NoPrivUpl
  265.     if !exists "t:privupl"$BBSName then goto NoPrivUpl
  266.  
  267.     cli $THORPath"bin/ScriptServ >\"t:privupl"$BBSName".tmp\" \""$BBSName"\" PrivUploadFile \"t:privupl"$BBSName"\""
  268.  
  269.     if !exists "t:privupl"$BBSName".tmp" then goto NoPrivUpl
  270.  
  271.     varfile "t:privupl"$BBSName".tmp"
  272.  
  273.     if !$doctrlx == "TRUE" then wait "Command"
  274.  
  275. PrivLoop:
  276.     readvar $dtmpfile    
  277.     if $dtmpfile == "" then goto PrivLoopEnd
  278.     if $dtmpfile == "EOF" then goto PrivLoopEnd
  279.     
  280.     send "F D "$dtmpfile"\n"
  281.     capture "t:filenote"$BBSName
  282.     gosub NoTimeout
  283.  
  284.     wait "Command"
  285.  
  286.     if !exists $LogFile then write $LogFile "Messages from script:\n"
  287.     write $LogFile "    Downloaded private file: "$dtmpfile"\n"
  288.  
  289.     capture off
  290.  
  291.     goto PrivLoop
  292.  
  293. PrivLoopEnd:
  294.     set $doctrlx = "TRUE"
  295.     varfile close
  296.     cli "delete >nil: \"t:privupl"$BBSName".tmp\""
  297.  
  298. NoPrivUpl:
  299.  
  300. ;***************** Get files in hold
  301.  
  302.     if exists "t:privupl"$BBSName then cli "delete >nil: \"t:privupl"$BBSName"\""
  303.     if !$gethold == "TRUE" then goto NoHold
  304.  
  305.     set $docmd = "F GET\n"
  306.     gosub DoCommand
  307.     gosub NoTimeout
  308.  
  309. NoHold:
  310. ;***************** Update filenotes of downloaded files.
  311.     if !exists "t:filenote"$BBSName then goto NoUpdateNotes
  312.  
  313.     if !$doctrlx == "TRUE" then wait "Command"
  314.     set $doctrlx = "TRUE"
  315.  
  316.     cli $THORPath"bin/ScriptServ \""$BBSName"\" UPDATEFILENOTES \"t:filenote"$BBSName"\""
  317.     cli "delete >nil: \"t:filenote"$BBSName"\""
  318.  
  319. NoUpdateNotes:
  320. ;***************** Ready for logout
  321.  
  322.     if exists "t:DoLogOut" then goto DoLogOut
  323.  
  324.     if $AutoLogoff == "n" then goto NoLogOut
  325.  
  326.     if exists "t:NoLogOut" then goto NoLogOut
  327.  
  328. DoLogOut:
  329.     set $docmd = "CHAT A U L 30 MF 0\n"
  330.     gosub DoCommand
  331.  
  332.     set $docmd = "G Y N Y\n"
  333.     gosub DoCommand
  334.  
  335.     when "\r\nNO CARRIER\r\n" goto Hanged
  336.     delay 2
  337.     repeat
  338.     hangup
  339.     delay 2
  340.     until !CARRIER
  341.  
  342. Hanged:
  343.     dlwhen
  344.     goto AllDone
  345.  
  346. NoLogOut:
  347.     set $docmd = "CHAT A U L 30 MF 0 W R\n"
  348.     gosub DoCommand
  349.  
  350.     dwhens
  351.     timeout 0
  352.  
  353. AllDone:
  354.     request on
  355.     end
  356.  
  357.  
  358. Hung:
  359.     beep
  360.     message "\nI think the board has hung."
  361.     message "\nTurn off this script within 20 seconds to stop me from logging out !!"
  362.     delay 20
  363.     beep
  364.     message "\nWARNING: Logout in progress.\n"
  365.     hangup
  366.     goto AllDone
  367.  
  368. SysOp:
  369.     send "Sorry, you are trying to chat with a script.\n"
  370.     send "Please put me back to the BBS at once.\n"
  371.     set $Timeouts = "0"
  372.     wait "SYSOP is going offline!"
  373.     set $Timeouts = "0"
  374.     return
  375.  
  376.  
  377. ;************************************************
  378. DoCommand:
  379.     if $doctrlx == "TRUE" then send "^X"
  380.     converse "Command" $docmd
  381.  
  382.     if !$rengrab == "" then gosub RenameGrab
  383.     if !$fixtimeout == "" then gosub SetupTimeout
  384.  
  385.     set $doctrlx = "FALSE"
  386.     return
  387.  
  388. ;************************************************
  389. NoTimeout:
  390.     set $fixtimeout = "d"
  391.     timeout 0
  392.     return
  393.  
  394. SetupTimeout:
  395.     set $fixtimeout = ""
  396.     set $Timeouts = "0"
  397.     timeout 60 gosub SendCTRLX
  398.     return
  399.  
  400. SendCTRLX:
  401.     set $fixtimeout = "d"
  402.     if $Timeouts == "2" then timeout 20 gosub Hung
  403.     if $Timeouts == "2" then send "^X"
  404.  
  405.     if $Timeouts == "1" then send $docmd
  406.     if $Timeouts == "1" then set $Timeouts = "2"
  407.  
  408.     if $Timeouts == "0" then send "^X"
  409.     if $Timeouts == "0" then set $Timeouts = "1"
  410.     return
  411.  
  412. Hung:
  413.     beep
  414.     message "\nI think the board has hung."
  415.     message "\nTurn off this script within 20 seconds to stop me from logging out !!"
  416.     delay 20
  417.     beep
  418.     message "\nWARNING: Logout in progress.\n"
  419.     hangup
  420.     goto AllDone
  421.  
  422. ;************************************************
  423. RenameGrab:
  424.     set $rengrab = ""
  425.     cli $THORPath"bin/ScriptServ \""$BBSName"\" RENAMEGRAB"
  426.     cli "run >nil: sys:rexxc/rx 'address THOR.01 RESCAN'"
  427.     return
  428.  
  429. ;************************************************
  430. ; Enter message subroutine
  431. ; Uses variables:
  432. ;    $conf     - conference for message
  433. ;    $sendto     - user message is to (Empty string is equal to ALL)
  434. ;    $subject    - subject of message
  435. ;    $msgfile    - file message is in
  436. ;    $private    - private message (0/!0)
  437. EnterMsg:
  438.  
  439.     readvar    $conf
  440.     readvar    $sendto
  441.     readvar    $msgfile
  442.     readvar    $subject
  443.     readvar    $private
  444.     if $private == "" then set $private = "0"
  445.     if !$private == "0" then set $private = "y"
  446.     if $private == "0" then set $private = "n"
  447.  
  448.     set $done = "TRUE"
  449.  
  450.     when "Private message" send $private"\n"
  451.     when "other users (Enter=N)" send "\n"
  452.     when "Send message to" send $sendto"\n"
  453.  
  454.     when "enter both the first AND" goto etomyself
  455.     when "that name is not registered" goto etomyself
  456.     when "ALL is not allowed here!" goto etomyself
  457.  
  458.     when "READ ONLY conference. Us" goto einpost1
  459.     when "not a member of this con" goto einpost2
  460.     when "Invalid conference selec" goto einpost3
  461.     when "Topics are:"              goto einpost4
  462.     when "Couldn't save msg!"       goto einpost5
  463.  
  464.     if $conf == $oldconf then goto InConf
  465.  
  466.     set $docmd = "J "$conf"\n"
  467.     gosub DoCommand
  468.     if $done == "FALSE" then goto enterRet
  469.  
  470.     set $oldconf = $conf
  471.  
  472. InConf:
  473.     if $sendto == "" then set $sendto = "ALL"
  474.  
  475.     set $docmd = "E\n"
  476.     gosub DoCommand
  477.     if $done == "FALSE" then goto enterRet
  478.  
  479.     set $dlewhen = "FALSE"
  480.     set $dox = ""
  481.  
  482.     gosub SendMessage
  483.     if $done == "FALSE" then goto enterRet
  484.  
  485. enterErr:
  486.     if $done == "TRUE" then wait "Command"
  487.     set $doctrlx = "TRUE"
  488.  
  489.     dlwhen
  490.     dlwhen
  491.     dlwhen
  492.     dlwhen
  493.     dlwhen
  494.     dlwhen
  495.     dlwhen
  496.     dlwhen
  497.     dlwhen
  498.     dlwhen
  499.     dlwhen
  500.  
  501. enterRet:
  502.     return
  503.  
  504. etomyself:
  505.     gosub Startlogfile
  506.     write $LogFile "    Conference "$conf", unable to enter message to "$sendto"\n"
  507.     send "^X\n"
  508.     set $done = "FALSE"
  509.  
  510.     goto enterErr
  511.  
  512. einpost5:
  513.     gosub Startlogfile
  514.     write $LogFile "    The BBS couldn't save the message.\n"
  515.     set $done = "FALSE"
  516.  
  517.     goto enterErr
  518.  
  519. einpost4:
  520.     gosub Startlogfile
  521.     write $LogFile "    Invalid conference topic: "$conf"\n"
  522.     send "\n"
  523.     wait "Command"
  524.     set $oldconf = ""
  525.     set $done = "FALSE"
  526.  
  527.     goto enterErr
  528.  
  529. einpost3:
  530.     gosub Startlogfile
  531.     write $LogFile "    Invalid conference selection: "$conf"\n"
  532.     set $oldconf = ""
  533.     gosub FixJoinErr
  534.     wait "Command"
  535.     set $done = "FALSE"
  536.  
  537.     goto enterErr
  538.  
  539. einpost2:
  540.     gosub Startlogfile
  541.     write $LogFile "    User "$sendto" in not a member of conference "$conf"\n"
  542.     set $done = "FALSE"
  543.  
  544.     goto enterErr
  545.  
  546. einpost1:
  547.     gosub Startlogfile
  548.     write $LogFile "    Conference "$conf" is READ ONLY\n"
  549.     set $done = "FALSE"
  550.  
  551.     goto enterErr
  552.  
  553.  
  554. ;************************************************
  555. ; Reply message subroutine
  556. ; Uses variables:
  557. ;    $conf         - conference for message
  558. ;    $replyto     - reply to message
  559. ;    $subject    - subject of message
  560. ;    $msgfile    - file message is in
  561. ;    $private    - private message (y/n)
  562. ;    $sendto        - user the message is to
  563. ReplyMsg:
  564.     readvar $conf
  565.     readvar $sendto
  566.     readvar $msgfile
  567.     readvar $dummy
  568.     readvar $subject
  569.     readvar $replyto
  570.     readvar $private
  571.     
  572.     if $private == "" then set $private = "0"
  573.     if !$private == "0" then set $private = "y"
  574.     if $private == "0" then set $private = "n"
  575.  
  576.     set $done = "TRUE"
  577.  
  578.     when "Private message"          send $private"\n"
  579.     when "Include original message" send "n\n"
  580.     when "READ ONLY conference you" goto readonlyconf
  581.     when "Invalid conference selec" goto invalidconf
  582.     when "Topics are:"              goto invalidtopic
  583.     when "not available for reply." goto notavail
  584.     when "Message not found !"      goto REnotfound
  585.     when "not a member of this con" goto nomember
  586.     when "Couldn't save msg!"       goto ReSaveErr
  587.  
  588.     if $conf == $oldconf then goto InConf2
  589.  
  590.     set $docmd = "J "$conf"\n"
  591.     gosub DoCommand
  592.     if $done == "FALSE" then goto replyRet
  593.  
  594.     set $oldconf = $conf
  595. InConf2:
  596.     set $docmd = "R RE "$replyto"\n"
  597.     gosub DoCommand
  598.     if $done == "FALSE" then goto replyRet
  599.  
  600.     set $dox = "^X"
  601.     gosub SendMessage
  602.     if $done == "FALSE" then goto replyRet
  603.  
  604. replyErr:
  605.     if $done == "TRUE" then wait "Command"
  606.     set $doctrlx = "TRUE"
  607.  
  608.     dlwhen
  609.     dlwhen
  610.     dlwhen
  611.     dlwhen
  612.     dlwhen
  613.     dlwhen
  614.     dlwhen
  615.     dlwhen
  616.  
  617. replyRet:
  618.     return
  619.  
  620. readonlyconf:
  621.     gosub Startlogfile
  622.     write $LogFile "    Conference "$conf" is READ ONLY, unable to reply message "$replyto"\n"
  623.     set $done = "FALSE"
  624.  
  625.     goto replyErr
  626.  
  627. invalidconf:
  628.     gosub Startlogfile
  629.     write $LogFile "    Invalid conference selection: "$conf", unable to reply message "$replyto"\n"
  630.     gosub FixJoinErr
  631.     wait "Command"
  632.     set $done = "FALSE"
  633.  
  634.     goto replyErr
  635.  
  636. invalidconf:
  637.     gosub Startlogfile
  638.     write $LogFile "    Invalid conference topic: "$conf", unable to reply message "$replyto"\n"
  639.     send "\n"
  640.     wait "Command"
  641.     set $done = "FALSE"
  642.  
  643.     goto replyErr
  644.  
  645. nomember:
  646.     gosub Startlogfile
  647.     write $LogFile "    "$sendto" is not member of conference: "$conf", unable to reply message "$replyto"\n"
  648.     set $done = "FALSE"
  649.  
  650.     goto replyErr
  651.  
  652. notavail:
  653.     gosub Startlogfile
  654.     write $LogFile "    Message "$replyto" in "$conf" not available for reply\n"
  655.     set $done = "FALSE"
  656.  
  657.     goto replyErr
  658.  
  659. REnotfound:
  660.     gosub Startlogfile
  661.     write $LogFile "    Message "$replyto" in "$conf" was not found, and was not available for reply\n"
  662.     set $done = "FALSE"
  663.  
  664.     goto replyErr
  665.  
  666. ReSaveErr:
  667.     wait "Command"
  668.     gosub Startlogfile
  669.     write $LogFile "    The BBS couldn't save the message.\n"
  670.     set $done = "FALSE"
  671.  
  672.     goto replyErr
  673.  
  674.  
  675. ;************************************************
  676. ; Subroutine for sending message
  677. SendMessage:
  678.     when "--7-" goto sendit
  679.     converse "Subject" $dox$subject"\n"
  680.     wait "--7-"
  681. sendit:
  682.     dlwhen
  683.     if $userinfo == "FALSE" then goto nouserinfo
  684.  
  685.     if $BBSType == "ABBS"     then gosub SendABBSClear
  686.     if $BBSType == "ABBS_QWK" then gosub SendABBSClear
  687.  
  688.     if $BBSType == "MBBS"     then send "^KC" 
  689.     if $BBSType == "MBBS_QWK" then send "^KC" 
  690.     
  691. nouserinfo:
  692.     send "^KZ"
  693.     ascsend $Path$msgfile
  694.  
  695.     send "\w^Z^Z"
  696.     return
  697.  
  698. ;************************************************
  699. ; ABBS clear editor
  700. SendABBSClear:
  701.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  702.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  703.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  704.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  705.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  706.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  707.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  708.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  709.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  710.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  711.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  712.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  713.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  714.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  715.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  716.     send "^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y" 
  717.     return
  718.  
  719.  
  720. ;************************************************
  721. Startlogfile:
  722.     if !exists $LogFile then write $LogFile "Messages from script:\n"
  723.     write $LogFile "Error in event nr "$eventnr":\n"
  724.     return
  725.  
  726. ;************************************************
  727. FixJoinErr:
  728.     if $BBSType == "MBBS" then converse "name to join" "\n"
  729.     if $BBSType == "MBBS_QWK" then converse "name to join" "\n"
  730.  
  731.     if $BBSType == "ABBS" then send "^K"
  732.     if $BBSType == "ABBS" then converse "Join conference:" "\n"
  733.  
  734.     if $BBSType == "ABBS_QWK" then send "^K"
  735.     if $BBSType == "ABBS_QWK" then converse "Join conference:" "\n"
  736.  
  737.     return
  738.  
  739. ;************************************************
  740. ; Join conference
  741. ; Uses variables:
  742. ;    $conf - conference to join
  743. JoinConf:
  744.     readvar $conf
  745.  
  746.     set $done = "TRUE"
  747.     when "Invalid conference sele" gosub joinerr
  748.     when "Topics are:" gosub topicserr
  749.  
  750.     set $docmd = "J "$conf"\n"
  751.     gosub DoCommand
  752.     set $oldconf = $conf
  753.  
  754.     wait "Command"
  755.     dlwhen 
  756.     dlwhen
  757.     set $doctrlx = "TRUE"
  758.     
  759.     return
  760.  
  761. joinerr:
  762.     gosub Startlogfile
  763.     write $LogFile "    Invalid conference selection: "$conf", Unable to join\n"
  764.     gosub FixJoinErr
  765.     set $oldconf = ""
  766.     set $done = "FALSE"
  767.     return
  768.  
  769. topicserr:
  770.     gosub Startlogfile
  771.     write $LogFile "    Invalid conference topic: "$conf", Unable to join\n"
  772.     send "\n"
  773.     set $oldconf = ""
  774.     set $done = "FALSE"
  775.     return
  776.     
  777. ;************************************************
  778. ; Resign conference
  779. ; Uses variables:
  780. ;    $conf - conference to resign
  781. ResignConf:
  782.     readvar $conf
  783.  
  784.     when "Invalid conference sele" goto resconferr
  785.     when "Topics are:" goto restopicerr
  786.  
  787.     set $done = "TRUE"
  788.     set $oldconf = ""
  789.  
  790.     set $docmd = "J "$conf"\n"
  791.     gosub DoCommand
  792.     if $done == "FALSE" then goto resignRet
  793.  
  794.     set $docmd = "RES Y\n"
  795.     gosub DoCommand
  796.     if $done == "FALSE" then goto resignRet
  797.  
  798. resignErr:
  799.     dlwhen
  800.     dlwhen
  801.  
  802.     wait "Command"
  803.     set $doctrlx = "TRUE"
  804.  
  805. resignRet:
  806.     return
  807.  
  808. resconferr:
  809.     gosub Startlogfile
  810.     write $LogFile "    Invalid conference selection: "$conf", unable to resign\n"
  811.     gosub FixJoinErr
  812.     set $done = "FALSE"
  813.     goto resignErr
  814.  
  815. restopicerr:
  816.     gosub Startlogfile
  817.     write $LogFile "    Invalid conference topic: "$conf", unable to resign\n"
  818.     send "\n"
  819.     set $done = "FALSE"
  820.     goto resignErr
  821.  
  822. ;************************************************
  823. ; Append a file to the en of the other.
  824. ; Uses variables:
  825. ;  $appendsource - File to append.
  826. ;  $appenddest   - Destination.
  827. AppendFile:
  828.     if !exists $appenddest then goto afNotExists
  829.  
  830.     cli "join >nil: \""$appenddest"\" \""$appendsource"\" TO \""$appenddest".tmp\""
  831.     cli "delete >nil: \""$appenddest"\""
  832.     cli "rename >nil: \""$appenddest".tmp\" \""$appenddest"\""
  833.     cli "delete >nil: \""$appendsource"\""
  834.     return    
  835.  
  836. afNotExists:
  837.     cli "rename >nil: \""$appendsource"\" \""$appenddest"\""
  838.     return
  839.  
  840.  
  841. ;************************************************
  842. GetConfList:
  843.     set $docmd = ""
  844.     gosub DoCommand
  845.  
  846.     set $done = "TRUE"
  847.     cli "Delete >nil: "$Path"Conferences.txt"
  848.     capture $Path"Conferences.txt"
  849.  
  850.     send "R SH A\n"
  851.  
  852.     wait "Command"
  853.     set $doctrlx = "TRUE"
  854.  
  855.     capture off
  856.  
  857.     return
  858.  
  859. ;************************************************
  860. ; Download file subroutine
  861. ; Uses variables:
  862. ;    $filename - name of file to download
  863. DownloadFile:
  864.  
  865.     readvar $filename
  866.  
  867.     set $done = "TRUE"
  868.  
  869.     set $fnotfound  = "FALSE"
  870.     set $fnotaccess = "FALSE"
  871.     set $DNnotavail = "FALSE"
  872.     set $fexpired   = "FALSE"
  873.  
  874.     when "File not found!"           set $fnotfound = "TRUE"
  875.     when "You are not allowed"       set $fnotaccess = "TRUE"
  876.     when "not available, please"     set $DNnotavail = "TRUE"
  877.     when "has expired."              set $fexpired = "TRUE"
  878.     when "ate files may not be move" set $dfnotmove = "TRUE"
  879.     set $gethold = "TRUE"
  880.     set $dfnotmove = "FALSE"
  881.  
  882.     set $dtmpfile = $filename
  883.  
  884.     set $docmd = "F ADD "$filename"\n"
  885.     gosub DoCommand
  886.     capture "t:filenote"$BBSName
  887.  
  888.     wait "Command"
  889.     capture off
  890.     if $fnotfound  == "TRUE" then gosub fnotfound
  891.     if $fnotaccess == "TRUE" then gosub fnotaccess
  892.     if $DNnotavail == "TRUE" then gosub DNnotavail
  893.     if $fexpired   == "TRUE" then gosub fexpired
  894.     if $dfnotmove  == "TRUE" then gosub dferr
  895.     gosub FixDnlWhens
  896.     set $doctrlx = "TRUE"
  897.     return
  898.  
  899. dferr:
  900.     send "F D "$dtmpfile"\n"
  901.     capture "t:filenote"$BBSName
  902.     gosub NoTimeout
  903.  
  904.     wait "Command"
  905.     capture off
  906.     return
  907.  
  908.  
  909. fnotaccess:
  910.     gosub Startlogfile
  911.     write $LogFile "Error: Unable to download file \""$dtmpfile"\", you don't have download access\n"
  912.     set $done = "FALSE"
  913.     return
  914.  
  915. fnotfound:
  916.     gosub Startlogfile
  917.     write $LogFile "Error: Unable to download file \""$dtmpfile"\", file not found\n"
  918.     set $done = "FALSE"
  919.     return
  920.  
  921. DNnotavail:
  922.     gosub Startlogfile
  923.     write $LogFile "Error: Unable to download file \""$dtmpfile"\", file not available.\n       Please check with sysop.\n"
  924.     set $done = "FALSE"
  925.     return
  926.  
  927. fexpired:
  928.     gosub Startlogfile
  929.     write $LogFile "Error: Unable to download file \""$dtmpfile"\", your file time expired\n"
  930.     return
  931.  
  932. FixDnlWhens:
  933.     dwhen "File not found!"
  934.     dwhen "You are not allowed"
  935.     dwhen "not available, please" 
  936.     dwhen "ate files may not be move"
  937.     dwhen "has expired."
  938.     return
  939.  
  940. ;************************************************
  941. ; Upload file subroutine
  942. ; Uses variables:
  943. ;    $filename    - name of file to upload
  944. ;    $filedescr    - short description of file
  945. ;    $notify        - download notification (y/n)
  946. ;    $detailed    - detailed description for file
  947. ;    $sendto        - private upload to user (empty string/"ALL" = public file)
  948. ;    $localfile    - path/filename to upload.
  949. ;    $conf            - Try to make file private to conf (if $conf != "")
  950.  
  951. UploadFile:
  952.  
  953.     readvar $filename
  954.     readvar $filedescr
  955.     readvar $sendto
  956.     readvar $conf
  957.     if !$BBSType == "MBBS" then goto Upl1
  958.     readvar $notify
  959.  
  960.     if $notify == "" then set $notify = "0"
  961.     if !$notify == "0" then set $notify = "y"
  962.     if $notify == "0" then set $notify = "n"
  963.     
  964. Upl1:
  965.     readvar $detailed
  966.     readvar $localfile
  967.  
  968.     set $msgfile = ""
  969.     set $done = "TRUE"
  970.  
  971.     if $localfile == "" then set $localfile = $UpLoadDir$filename
  972.     if !exists $localfile then goto nofileupload
  973.  
  974.     if $conf == "" then goto AfterUplJoin
  975.  
  976.     when "Invalid conference sele" gosub joinerr
  977.     when "Topics are:" gosub topicserr
  978.  
  979.     set $docmd = "J "$conf"\n"
  980.     gosub DoCommand
  981.     set $oldconf = $conf
  982.  
  983.     wait "Command"
  984.                                                                                                                       dlwhen 
  985.     dlwhen           
  986.     set $doctrlx = "TRUE"
  987.     
  988.     if $done == "FALSE" then goto uplRet
  989.     
  990.  
  991. AfterUplJoin:
  992.  
  993.     when "enter both the first AND" goto puperr
  994.     when "that name is not registered" goto puperr
  995.     when "ALL is not allowed here!" goto puperr
  996.  
  997.     when "Invalid file name!" goto upinvfile
  998.     when "File exists already" goto fexists
  999.     when "You are not allowed" goto UPnotallowed
  1000.     when "each download" send $notify"\n"
  1001.  
  1002.     when "file to be publicly ava" send "\n"
  1003.     when "Directory name, <?>=lis" send "\n"
  1004.  
  1005.     if  $conf == "" then when "rivate to confer" send "n\n"
  1006.     if !$conf == "" then when "rivate to confer" send "y\n"
  1007.  
  1008.     if !$sendto == "" then set $docmd = "F PUP "$sendto"\n"
  1009.     if $sendto == "ALL" then set $docmd = "F UP\n"
  1010.     if $sendto == "" then set $docmd = "F UP\n"
  1011.  
  1012.     gosub DoCommand
  1013.     if $done == "FALSE" then goto uplRet
  1014.  
  1015.     converse "ile name" $filename"\n"
  1016.     converse "ion of file" $filedescr"\n"
  1017.  
  1018.     wait "B01"
  1019.  
  1020.     upload $localfile,Z
  1021.     gosub NoTimeout
  1022.  
  1023.     when "Command" goto uplfail
  1024.  
  1025.     if $detailed == "" then goto NoDetailed
  1026.  
  1027.     converse "description (Enter=Y)" "Y\n"
  1028.     gosub SetupTimeout
  1029.     set $msgfile = $detailed
  1030.     gosub SendMessage
  1031.     if $done == "FALSE" then goto uplRet
  1032.     goto uplLateErr
  1033.  
  1034. NoDetailed:
  1035.     converse "description (Enter=Y)" "N\n"
  1036.  
  1037. uplLateErr:
  1038.     dlwhen
  1039. uplErr:
  1040.     dlwhen    
  1041.     dlwhen
  1042.     dlwhen
  1043.     dlwhen
  1044.     dlwhen
  1045.     dlwhen
  1046.     dlwhen
  1047.     dlwhen
  1048.     dlwhen
  1049.  
  1050.     wait "Command"
  1051.     set $doctrlx = "TRUE"
  1052. uplRet:
  1053.     return
  1054.  
  1055. puperr:
  1056.     gosub Startlogfile
  1057.     write $LogFile "Error: Unable to do a private upload of "$filename"\n"
  1058.     write $LogFile "       User "$sendto" is not registered\n"
  1059.     send "^X\n"
  1060.     set $done = "FALSE"
  1061.     goto uplErr
  1062.  
  1063. upinvfile:
  1064.     gosub Startlogfile
  1065.     write $LogFile "Error: Unable to upload "$filename", filename is invalid\n"
  1066.     send "^X\n"
  1067.     set $done = "FALSE"
  1068.     goto uplErr
  1069.  
  1070. fexists:
  1071.     gosub Startlogfile
  1072.     write $LogFile "Error: Unable to upload "$filename", file already exists\n"
  1073.     send "^X\n"
  1074.     set $done = "FALSE"
  1075.     goto uplErr
  1076.  
  1077. UPnotallowed:
  1078.     gosub Startlogfile
  1079.     write $LogFile "Error: Unable to upload "$filename", you don't have download access\n"
  1080.     set $done = "FALSE"
  1081.     goto uplErr
  1082.  
  1083. uplfail:
  1084.     gosub Startlogfile
  1085.     write $LogFile "Error: Unable to upload "$filename", upload failed\n"
  1086.     set $done = "FALSE"
  1087.     set $doctrlx = "TRUE"
  1088.     goto uplLateErr
  1089.  
  1090. nofileupload:
  1091.     gosub Startlogfile
  1092.     write $LogFile "Error: Unable to upload "$filename", file not found\n"
  1093.     set $done = "FALSE"
  1094.     goto uplRet
  1095.  
  1096. ;************************************************
  1097. ; Do a custom command
  1098. ; Uses variables:
  1099. ;  $commandstring - Command to execute.
  1100. CommandEvent:
  1101.     readvar $commandstring
  1102.  
  1103.     write $LogFile "Executing custom command:\n"
  1104.  
  1105.     set $docmd = $commandstring"\n"
  1106.     gosub DoCommand
  1107.  
  1108.     capture $LogFile
  1109.  
  1110.     gosub NoTimeout
  1111.  
  1112.     when "File Command"      goto CmdEvDone
  1113.     when "Main Command"      goto CmdEvDone
  1114.     when "Utility Command"   goto CmdEvDone
  1115.     when "SYSOP Command"     goto CmdEvDone
  1116.     when "SIGOP Command"     goto CmdEvDone
  1117.     when "Misc Command"      goto CmdEvDone
  1118.     when "Mark Command"      goto CmdEvDone
  1119.     when "Read Ref Command"  goto CmdEvDone
  1120.     
  1121.     wait "Read Command"
  1122.  
  1123. CmdEvDone:
  1124.     dlwhen
  1125.     dlwhen
  1126.     dlwhen
  1127.     dlwhen
  1128.     dlwhen
  1129.     dlwhen
  1130.     dlwhen
  1131.     dlwhen
  1132.  
  1133.     capture off
  1134.     write $LogFile "\n"
  1135.     set $done = "TRUE"
  1136.     set $doctrlx = "TRUE"
  1137.     set $oldconf = ""
  1138.     return
  1139.  
  1140. ;************************************************
  1141. ; Send user info
  1142. ; Uses variables:
  1143. ;    $msgfile    - file user info is in
  1144. SendUserInfo:
  1145.     readvar $msgfile
  1146.  
  1147.     when "no resumé user info on this" goto NoUserInfo
  1148.  
  1149.     set $docmd = "Q EDIT\n"
  1150.     gosub DoCommand
  1151.  
  1152.     converse "number displayed (Enter=" "y\n"
  1153.  
  1154.     set $userinfo = "TRUE"
  1155.  
  1156.     gosub SendMessage
  1157.  
  1158.     set $userinfo = "FALSE"
  1159.     set $done = "TRUE"
  1160.  
  1161. uinErr:
  1162.     wait "Command"
  1163.     set $doctrlx = "TRUE"
  1164.  
  1165.     dlwhen
  1166.  
  1167.     return
  1168.  
  1169. NoUserInfo:
  1170.     gosub Startlogfile
  1171.     write $LogFile "Error: Sorry, no resumé user info on this system!"
  1172.     goto uinErr    
  1173.  
  1174.  
  1175. ;************************************************
  1176. ; Set up BBS configuration
  1177. ConfigureBBS:
  1178.     if $BBSType == "MBBS" then goto SetMBBSMode
  1179.     if $BBSType == "MBBS_QWK" then goto SetMBBSMode
  1180.  
  1181.     set $docmd = "R\n"
  1182.     gosub DoCommand
  1183.     when "Read Ref Co" set $readmode = "1"
  1184.     when "Read Co" set $readmode = "2"
  1185.     wait "Command"
  1186.     dlwhen
  1187.     dlwhen
  1188.     set $doctrlx = "TRUE"
  1189.     if $readmode == "2" then goto AfterSetMode
  1190.     set $docmd = "MODE\n"
  1191.     gosub DoCommand
  1192.     goto AfterSetMode
  1193.  
  1194. SetMBBSMode:
  1195.     set $qwkcfg = "TRUE"
  1196.  
  1197.     set $docmd = "R MODE M\n"
  1198.     gosub DoCommand
  1199.  
  1200. AfterSetMode:
  1201.     set $docmd = "u m y "$AnsiMenues" "$UseColors" y n y\n"
  1202.     gosub DoCommand
  1203.  
  1204.     if $BBSType == "ABBS" then gosub SetSpNN
  1205.     if $BBSType == "ABBS_QWK" then gosub SetSpNN
  1206.  
  1207.     if $BBSType == "ABBS_QWK" then set $docmd = "gf b "$Bulletins"\n"
  1208.     if $BBSType == "ABBS_QWK" then gosub DoCommand
  1209.  
  1210.     set $docmd = "u addr\n"
  1211.     gosub DoCommand
  1212.  
  1213.     converse "treet address" "^X"$UserStreet"\n"
  1214.     converse "code and town" "^X"$UserAddress"\n"
  1215.  
  1216.     if $UserPhone == "" then set $UserPhone = "-"
  1217.     converse "ome telephone number" "^X"$UserPhone"\n"
  1218.  
  1219.     converse "ork telephone number" "\n"
  1220.  
  1221.     wait "Command"
  1222.     set $doctrlx = "TRUE"
  1223.     set $done = "TRUE"
  1224.     return
  1225.  
  1226. SetSpNN:
  1227.     set $docmd = "sp n n\n"
  1228.     gosub DoCommand
  1229.     return
  1230.  
  1231. ;************************************************
  1232. ; Set get new files flag.
  1233. ; Uses variables:
  1234. ;    $newfilesdate    - date to use for newfiles.
  1235.  
  1236. GetNewFiles:
  1237.  
  1238.     readvar $newfilesdate
  1239.  
  1240.     set $NewFiles = "y"
  1241.     set $done = "TRUE"
  1242.  
  1243.     return
  1244.  
  1245.  
  1246. ;************************************************
  1247. ; Set the autologoff flag.
  1248. ; Uses variables:
  1249. ;  $boolean - Logoff (y/n)
  1250. AutoLogOff:
  1251.     readvar $boolean
  1252.  
  1253.     set $AutoLogoff = "y"
  1254.     if $boolean == "0" then set $AutoLogoff = "n"
  1255.     set $done = "TRUE"
  1256.  
  1257.     return
  1258.  
  1259. ;************************************************
  1260. ; Retract a message.
  1261. ; Uses variables:
  1262. ;  $conf     - Conference the message is in.
  1263. ;  $reforgnr - Number of message to kill.
  1264. RetractMsg:
  1265.     readvar $conf
  1266.     readvar $reforgnr
  1267.  
  1268.     set $docmd = "j "$conf" "$reforgnr" kill\n"
  1269.     gosub DoCommand
  1270.  
  1271.     wait "Command"
  1272.     set $doctrlx = "TRUE"
  1273.     set $done = "TRUE"
  1274.     return
  1275.  
  1276. ;************************************************
  1277. ; Retract a file
  1278. ; Uses variables:
  1279. ;  $filename - File name to kill
  1280. RetractFile:
  1281.     readvar $filename
  1282.  
  1283.     set $docmd = "f ret "$filename " y\n"
  1284.     gosub DoCommand
  1285.  
  1286.     wait "Command"
  1287.     set $doctrlx = "TRUE"
  1288.     set $done = "TRUE"
  1289.     return
  1290.  
  1291. AFrontDetect:
  1292.     send "\e\e"
  1293.     message "\nA nice front door escaped!\n"
  1294.     return
  1295.